// 测试淘汰管理API调用
const axios = require('axios');

// 模拟淘汰管理更新请求
async function testEliminationUpdate() {
  try {
    const requestData = {
      Id: 15,
      EliminationDate: "2025-07-28T00:00:00.000Z",
      SheepFilesId: "SF001",
      Breed: "品种修改",
      House_typeId: 5,
      Field: 3,
      LeaveStatus: true,
      EliminationReason: "没有",
      Handling_measuresId: 2,
      SheepTypeId: 3
    };

    console.log('发送的请求数据:', JSON.stringify(requestData, null, 2));

    const response = await axios.put('http://39.96.200.62:8511/api/CullingManagement/Update/update', requestData, {
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer ' + (localStorage.getItem('Token') || '')
      }
    });

    console.log('响应状态:', response.status);
    console.log('响应数据:', response.data);
  } catch (error) {
    console.error('请求失败:', error.response?.data || error.message);
  }
}

// 测试获取详情
async function testGetDetail() {
  try {
    const response = await axios.get('http://39.96.200.62:8511/api/CullingManagement/Detail/detail/15', {
      headers: {
        'Authorization': 'Bearer ' + (localStorage.getItem('Token') || '')
      }
    });

    console.log('获取详情响应:', response.data);
  } catch (error) {
    console.error('获取详情失败:', error.response?.data || error.message);
  }
}

// 运行测试
console.log('开始测试淘汰管理API...');
testGetDetail().then(() => {
  console.log('获取详情测试完成');
  return testEliminationUpdate();
}).then(() => {
  console.log('更新测试完成');
}).catch(error => {
  console.error('测试过程中出现错误:', error);
}); 